package com.datechange.utils;

public class WindowsService {

	public static final String SERVICE_STARTUP_AUTO = "auto";
	public static final String SERVICE_STARTUP_DISABLED = "disabled";
	public static final String SERVICE_STARTUP_MANUAL = "demand";

	public static void serviceStop(String serviceNmae) {
		CommandExecutor.runCommand(prepareCommand("net stop "+serviceNmae ));
	}

	public static void serviceStart(String serviceNmae) {
		CommandExecutor.runCommand(prepareCommand("net start "+serviceNmae ));
	}

	public static void serviceStartUpTypeChange(String serviceNmae, String option) {
		CommandExecutor.runCommand(prepareCommand("sc config "+ serviceNmae +" start= "+option));
	}

	private static String[] prepareCommand(String mainCommand){
		String[] command = new String[3];
		command[0] = "cmd";
		command[1] = "/c"; // "/C" command Executes the specified command and returns.
		command[2] = mainCommand;
		return command;
	}

}
